package com.huawei.M01.iterator.M20;

import java.util.Arrays;
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
import java.util.stream.Stream;

/**
 * 1012. 至少有 1 位重复的数字
 *
 * @author 111
 */
public class NumDup {
    public int numDupDigitsAtMostN(int n) {
        int res = 0;
        for (int i = 1; i <= n; i++) {
            if (hasRepeatNum(i)) {
                res++;
            }
        }
        return res;
    }

    private boolean hasRepeatNum(int input) {
        long count = Arrays.stream(String.valueOf(input).split("")).distinct().count();
        if (count < String.valueOf(input).length()) {
            return true;
        }
        return false;
    }

    public static void main(String[] args) {
        System.out.println(new NumDup().numDupDigitsAtMostN(1000));
    }
}
